package cn.zhizihua.domain.query;

import cn.zhizihua.domain.po.User;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.Data;

@Data
public class UserQuery extends BaseQuery{

    private String userName;
    private String realName;
    private Integer gender;
    private String phone;
    private Integer delTag;

    @Override
    public Wrapper getQueryWrapper() {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(userName)){
            queryWrapper.like("userName",userName);
        }
        if (StringUtils.isNotEmpty(realName)){
            queryWrapper.like("realName",realName);
        }
        System.out.println("gender----"+gender);
        System.out.println(gender==null);
        if (gender!=null && (gender==0 || gender==1)){
            queryWrapper.eq("gander",gender);
        }
        if (StringUtils.isNotEmpty(phone)){
            queryWrapper.like("userName",phone);
        }
        if (delTag!=null && (delTag==0 || delTag==1)){
            queryWrapper.eq("delTag",delTag);
        }
        queryWrapper.orderByDesc("userId");
        return queryWrapper;
    }
}
